import { NotificationArgsProps } from 'ant-design-vue/es/notification';
import { useAppFeedback } from './useAppFeedback';
import { type ArgsProps } from 'ant-design-vue/es/notification/interface';

/** 快速通知参数类型（全可选） */
type FastArgsProps = Partial<ArgsProps>;

interface FastOption {
  message?: string;
  description?: string;
}
interface FastOptions {
  success?: FastOption;
  warning?: FastOption;
  error?: FastOption;
}

/**
 * 使用应用反馈的通知
 * @param fastOptions 快速选项
 */
export function useAppNotification(fastOptions?: FastOptions) {
  const { notification: n } = useAppFeedback();

  /** 快速成功默认参数 */
  const fastSuccessArgsProps: ArgsProps = {
    message: fastOptions?.success?.message ?? '提示',
    description: fastOptions?.success?.description ?? '操作成功！',
  };
  /** 快速警告默认参数 */
  const fastWarningArgsProps: ArgsProps = {
    message: fastOptions?.warning?.message ?? '提示',
    description: fastOptions?.warning?.description ?? '操作失败！',
  };
  /** 快速错误默认参数 */
  const fastErrorArgsProps: ArgsProps = {
    message: fastOptions?.error?.message ?? '提示',
    description: fastOptions?.error?.description ?? '发生错误！',
  };

  const notification = {
    success: n.success,
    error: n.error,
    info: n.info,
    warning: n.warning,
    open: n.open,
    destroy: n.destroy,
    /** 快速成功提示 */
    fastSuccess: (args?: FastArgsProps) => n.success({ ...fastSuccessArgsProps, ...args }),
    /** 快速警告提示 */
    fastWarning: (args?: FastArgsProps) => n.warning({ ...fastWarningArgsProps, ...args }),
    /** 快速错误提示 */
    fastError: (args?: FastArgsProps) => n.error({ ...fastErrorArgsProps, ...args }),
  };

  return {
    notification,
  };
}
